<f:view xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:fn="http://java.sun.com/jsp/jstl/functions"
        xmlns:g="http://code.google.com/p/ada-ado/generator"
        xmlns:f="http://java.sun.com/jsf/core"
        file="#{projectName}-server.adb">-----------------------------------------------------------------------
--  #{fn:capitalize(projectName)}-server -- Application server
--  Copyright (C) 2011 XXX
--  Written by XXX (XXX)
--
--  Licensed under the Apache License, Version 2.0 (the "License");
--  you may not use this file except in compliance with the License.
--  You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
--  Unless required by applicable law or agreed to in writing, software
--  distributed under the License is distributed on an "AS IS" BASIS,
--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--  See the License for the specific language governing permissions and
--  limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Exceptions;

with ASF.Server.Web;

with AWA.Applications;
with ASF.Applications.Main;
with ADO.Drivers;
with ASF.Servlets.Faces;
with ASF.Servlets.Files;
with ASF.Servlets.Measures;
with ASF.Filters.Dump;
procedure #{fn:capitalize(projectName)}.Server is

   use AWA.Applications;

   CONTEXT_PATH : constant String := "/#{projectName}";

   App     : AWA.Applications.Application_Access := new AWA.Applications.Application;
   C       : ASF.Applications.Config;
   Faces   : aliased ASF.Servlets.Faces.Faces_Servlet;
   Files   : aliased ASF.Servlets.Files.File_Servlet;
   Dump    : aliased ASF.Filters.Dump.Dump_Filter;
   Perf    : aliased ASF.Servlets.Measures.Measure_Servlet;

   Fact    : ASF.Applications.Main.Application_Factory;
   WS      : ASF.Server.Web.AWS_Container;
begin

   ADO.Drivers.Initialize;

   C.Load_Properties ("#{projectName}.properties");
   App.Initialize (C, Fact);

   App.Register ("layoutMsg", "layout");
   App.Set_Global ("contextPath", CONTEXT_PATH);

   App.Set_Global ("version", "0.1");

   --  Register the servlets and filters
   App.Add_Servlet (Name => "faces", Server => Faces'Unchecked_Access);
   App.Add_Servlet (Name => "files", Server => Files'Unchecked_Access);
   App.Add_Servlet (Name => "perf", Server => Perf'Unchecked_Access);
   App.Add_Filter (Name => "dump", Filter => Dump'Unchecked_Access);
   App.Add_Filter (Name => "perf", Filter => Perf'Unchecked_Access);

--   Register (App    => App.all'Access,
--             Name   => "words", URI => "words",
--             Module => VStat.Words.Module.Instance.all'Access);

   C.Set ("view.dir", "web");

   --  Define servlet mappings
   App.Add_Mapping (Name => "faces", Pattern => "*.html");
   App.Add_Mapping (Name => "files", Pattern => "*.css");
   App.Add_Mapping (Name => "files", Pattern => "*.js");
   App.Add_Mapping (Name => "files", Pattern => "*.png");
   App.Add_Mapping (Name => "perf", Pattern => "statistics.xml");
   App.Add_Filter_Mapping (Name => "perf", Pattern => "*.html");
   App.Add_Filter_Mapping (Name => "dump", Pattern => "*.html");
   App.Add_Filter_Mapping (Name => "perf", Pattern => "*.css");
   App.Add_Filter_Mapping (Name => "perf", Pattern => "*.png");

   WS.Register_Application (CONTEXT_PATH, App.all'Access);

   WS.Start;

   delay 365.0 * 24.0 * 3600.0;

   App.Close;
exception
   when E: others =>
      Ada.Text_IO.Put_Line ("Exception in server: " &amp;
                            Ada.Exceptions.Exception_Name (E) &amp; ": " &amp;
                            Ada.Exceptions.Exception_Message (E));
end #{fn:capitalize(projectName)}.Server;
</f:view>
